package com.hq.fxh.Utils;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.SimpleTarget;
import com.hq.fxh.R;
import com.hq.fxh.imageLoader.IImageLoader;

import java.io.File;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description : glide工具lei
 * @Created 2017/8/10
 * @Email xlwenhao1858@sina.com
 */


public class GlideUtils implements IImageLoader {

    public static void loadImage(Context context, String imageUrl, ImageView imageView) {
        Glide.with(context)
                .load(imageUrl)
                .dontAnimate()
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(imageView);
    }

    public static void loadImageViewCen(Context mContext, String path, ImageView mImageView) {
        Glide.with(mContext).load(path).into(mImageView);
    }

    public static void loadImageView(Context mContext, String path, ImageView mImageView) {
        Glide.with(mContext).load(path).centerCrop().into(mImageView);
    }

    public static void loadImageViewFromMipmap(Context mContext, Integer resourceId, ImageView mImageView) {
        Glide.with(mContext).load(resourceId).centerCrop().into(mImageView);
    }

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        Glide.with(activity)                             //配置上下文
                .load(Uri.fromFile(new File(path)))      //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
                .error(R.drawable.ic_launcher)           //设置错误图片
                .placeholder(R.drawable.ic_arrow_back)     //设置占位图片
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .skipMemoryCache(true)
                .into(imageView);
    }

    @Override
    public void clearMemoryCache(Activity activity) {

    }
}
